package com.chinafree.permission.converter;

import com.chinafree.permission.model.bo.RoleDepartUserEditBO;
import com.chinafree.permission.model.bo.RolePermissionEditBO;
import com.chinafree.permission.model.dto.PermissionDTO;
import com.chinafree.permission.model.dto.RoleDTO;
import com.chinafree.permission.model.param.RoleDepartUserEditParam;
import com.chinafree.permission.model.param.RoleParam;
import com.chinafree.permission.model.param.RolePermissionEditParam;
import com.chinafree.permission.model.po.PermissionPO;
import com.chinafree.permission.model.po.RolePO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface RolePermissionConverter {
    RolePermissionConverter INSTANCE = Mappers.getMapper(RolePermissionConverter.class);

    List<RoleDTO> rolePOListToRoleDTOList(List<RolePO> rolePOS);

    RoleDTO rolePOToRoleDTO(RolePO rolePO);
    RolePO roleParamToRolePO(RoleParam roleParam);

    default RolePermissionEditBO rolePermissionParamToEditBO(RolePermissionEditParam rolePermissionEditParam){
       if(rolePermissionEditParam==null){
           return null;
       }
       return RolePermissionEditBO.builder()
           .roleId(rolePermissionEditParam.getRoleId())
           .permissionIdList(rolePermissionEditParam.getPermissionIdList())
           .build();
    }
    default RoleDepartUserEditBO roleUserAndDepartParamToEditBO(RoleDepartUserEditParam roleDepartUserEditParam){
       if(roleDepartUserEditParam==null){
           return null;
       }
       return RoleDepartUserEditBO.builder()
           .roleId(roleDepartUserEditParam.getRoleId())
           .userList(roleDepartUserEditParam.getUserList())
           .build();
    }
    List<PermissionDTO> permissionPOListToPermissionDTOList(List<PermissionPO> permissionPOS);



}
